<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>hello vue</title>
</head>

<body>
    <div id="app">
        <input type="text" v-focus>
        <input type="text" v-color="param">
    </div>

    <script type="text/javascript" src="js/vue.js"></script>
    <script type="text/javascript">
        var vm = new Vue({
            el: '#app',
            data: {
                param: {
                    color: 'red'
                }
            },
            methods: {

            },
            directives: {
                color: {
                    bind: function (el, binding) {
                        // 根据指令的参数设置背景色
                        el.style.backgroundColor = binding.value.color;
                    }
                },
                focus: {
                    inserted: function (el) {
                        el.focus();
                    }
                }
            }
        });
    </script>
</body>

</html>